From 4259301081c3ade8329c8330cc61b78c5dad2dc0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Tue, 23 Aug 2005 07:41:51 +0000 Subject: [PATCH] Add reference counting to the babl library --- ChangeLog | 11 +++++++++++ babl/babl.c | 44 +++++++++++++++++++++++++------------------- 2 files changed, 36 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3550555..b5f82d9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2005-08-22 Øyvind Kolås + + * babl/babl.c: implement ref counting to avoid unneccesary destruction + of static data when multiple instances of babl is used in an + adressspace. + +2005-08-23 Øyvind Kolås + + * tests/Makefile.am: + * tests/babl_class_name.c: new test. + 2005-08-22 Øyvind Kolås * babl/babl-classes.h: (BabPixelFormat): only a single BablModel. diff --git a/babl/babl.c b/babl/babl.c index a19477f..ddbc1bd 100644 --- a/babl/babl.c +++ b/babl/babl.c @@ -23,32 +23,38 @@ #include "babl-sanity.h" #include "babl-introspect.h" +static int ref_count=0; + void babl_init (void) { - babl_type_init (); - babl_sampling_init (); - babl_component_init (); - babl_model_init (); - babl_pixel_format_init (); - babl_conversion_init (); - babl_base_init (); - - babl_sanity (); + if (ref_count++==0) + { + babl_type_init (); + babl_sampling_init (); + babl_component_init (); + babl_model_init (); + babl_pixel_format_init (); + babl_conversion_init (); + babl_base_init (); + babl_sanity (); + } } void babl_destroy (void) { - /* babl_base is destroy by the containing types */ - - babl_fish_destroy (); - babl_conversion_destroy (); - babl_pixel_format_destroy (); - babl_model_destroy (); - babl_component_destroy (); - babl_sampling_destroy (); - babl_type_destroy (); + /* babl_base is destroyed by the containing types */ - babl_memory_sanity (); + if (!--ref_count) + { + babl_fish_destroy (); + babl_conversion_destroy (); + babl_pixel_format_destroy (); + babl_model_destroy (); + babl_component_destroy (); + babl_sampling_destroy (); + babl_type_destroy (); + babl_memory_sanity (); + } } -- 2.30.2